package com.sitech.portal.system.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.sitech.ibnms.common.form.TreeNode;
import com.sitech.ibnms.core.IPage;
import com.sitech.ibnms.core.PageForm;
import com.sitech.portal.system.dao.ISysSubSystemDao;
import com.sitech.portal.system.service.ISysSubSystemService;

public class SysSubSystemServiceImpl implements ISysSubSystemService {

	private ISysSubSystemDao sysSubSystemDao;
	
	public ISysSubSystemDao getSysSubSystemDao() {
		return sysSubSystemDao;
	}

	public void setSysSubSystemDao(ISysSubSystemDao sysSubSystemDao) {
		this.sysSubSystemDao = sysSubSystemDao;
	}

	@Override
	public void add(HashMap map) {
		// TODO Auto-generated method stub
		sysSubSystemDao.add(map);
	}

	@Override
	public void deleteForTB_SYS_SUB_SYSTEMByPK(String SYSTEM_ID) {
		// TODO Auto-generated method stub
		sysSubSystemDao.deleteForTB_SYS_SUB_SYSTEMByPK(SYSTEM_ID);
	}

	@Override
	public IPage findListSubSystem(PageForm pageForm) {
		// TODO Auto-generated method stub
		return sysSubSystemDao.findListSubSystem(pageForm);
	}

	@Override
	public List findListSubSystemForTree(String ROLE_ID) {
		// TODO Auto-generated method stub
		return sysSubSystemDao.findListSubSystemForTree(ROLE_ID);
	}

	@Override
	public HashMap findObjForTB_SYS_SUB_SYSTEMByPK(String SYSTEM_ID) {
		// TODO Auto-generated method stub
		return sysSubSystemDao.findObjForTB_SYS_SUB_SYSTEMByPK(SYSTEM_ID);
	}

	@Override
	public List findSUB_SYSTEMByLoginID(String LOGIN_ID) {
		// TODO Auto-generated method stub
		return sysSubSystemDao.findSUB_SYSTEMByLoginID(LOGIN_ID);
	}

	@Override
	public List findSubSystemListByLoginID(String LOGIN_ID) {
		// TODO Auto-generated method stub
		return sysSubSystemDao.findSubSystemListByLoginID(LOGIN_ID);
	}

	@Override
	public void update(HashMap map) {
		// TODO Auto-generated method stub
		sysSubSystemDao.update(map);
	}

	@Override
	public List<TreeNode> loadModuleRootNode(String loginId) {
		List<TreeNode> treeNodes = new ArrayList<TreeNode>();
		List result = findSubSystemListByLoginID(loginId);
		for(Object obj : result){
			HashMap map = (HashMap)obj;
			TreeNode treeNode = new TreeNode();
			treeNode.setId(""+map.get("SYSTEM_ID"));
			treeNode.setpId(null);
			treeNode.setName(""+map.get("SYSTEM_NAME"));
			treeNodes.add(treeNode);
		}
		return treeNodes;
	}

}
